#pragma once
#include"RBTree.h"

namespace cx
{
	

	template<class K>
	class set
	{
		struct SetKeyOfT
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};
	public:
		typedef typename RBTree<K,const K, SetKeyOfT>::Iterator iterator;

		iterator begin()
		{
			return _t.Begin();
		}

		iterator end()
		{
			return _t.End();
		}
		
		pair<iterator, bool> insert(const K& key)
		{
			return _t.Insert(key);
		}

		iterator find(const K& key)
		{
			return _t.Find(key);
		}

		void inorder()
		{
			_t.InOrder();
		}
	private:
		RBTree<K,const K, SetKeyOfT> _t;
	};

	void settest1()
	{
		set<int> s;
		for (int i = 9; i > 0; i--)
		{
			s.insert(i);
		}

		for (auto e : s)
		{
			cout << e << ' ';
		}
		cout << endl;

		
		set<int>::iterator it = s.end();
		while (it != s.begin())
		{
			--it;
			cout << *it << ' ';
		}
		cout << endl;

		it = s.find(5);
		if (it != s.end())
			cout << *it << endl;

		it = s.find(100);
		if (it != s.end())
			cout << *it << endl;

		//s.inorder();
		cout << endl;
	}
}